let axios = require('axios').default;
module.exports = {
    get: function(baseUrl, params, proxy) {
        const src = axios.CancelToken.source();
        const timeout = setTimeout(() => {
            src.cancel();
            // Timeout Logic
        }, 120000);
        return axios({
            method: 'get',
            url: baseUrl,
            params: params,
            headers: {
                'User-Agent': 'Mix',
                'Accept': 'application/xml,text/xml,application/rss+xml,application/atom+xml,application/xhtml+xml',
                'Content-Type': 'text/xml;application/xml;charset=UTF-8'
            },
            proxy: proxy,
            timeout: 2 * 60 * 1000,
            cancelToken: src.token // timeout bug walkaround;
        }).then(data => {
            clearTimeout(timeout);
            return Promise.resolve(data);
        }).catch(err => {
            return Promise.reject(err);
        })
    }
}